﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using TSSControlLibrary;

namespace TaskSchedulingSystemForm
{
    class UserControlWriter:TextWriter
    {        
         DisPlayIOInfoUserControl userControl;
        delegate void Voidaction();
        public UserControlWriter( DisPlayIOInfoUserControl u)
        {
            userControl = u;         
        }
        /// <summary>
        /// 重定向标准输出 向模拟的控制台输出一行字符
        /// </summary>
        /// <param name="value"></param>
        public override void WriteLine(string value)
        {
            int threadId = Thread.CurrentThread.ManagedThreadId;
            Voidaction action = delegate
            {
                userControl.WriteOneLine(value);
            };       
            userControl.BeginInvoke(action);
        }      
         public override System.Text.Encoding Encoding
        {
            get { return System.Text.Encoding.UTF8; }
        }
    }
}
